fix: typescript date mapping#2393
Conversation
✅ Deploy Preview for modelina canceled.
|
jonaslagoni
left a comment
There was a problem hiding this comment.
Looks like you need to format the code npm run lint:fix
Since we now support Date as native type, we need to double check that the serialization preset still works as expected.
Add a new property with a date/date-time format for
and then runnpm run generate:runtime:typescript and then adapt the test files such as
to add date time format and see if it can serialize and de-serialize it correctly.
You can also run npm run test:runtime:typescript to test all the files.
|
Hey @jonaslagoni I’ve addressed the review feedback by adding a date-time field to the runtime input used for TypeScript tests and verifying correct Date serialization/deserialization. All runtime tests are now passing. Lemme know if further changes are needed |
jonaslagoni
left a comment
There was a problem hiding this comment.
Just one change I think if CI goes through.
Mind adding a section to the migration docs for v5-6 about this change?
|
|
@all-contributors please add @AarishMansur for code, test |
|
I've put up a pull request to add @AarishMansur! 🎉 |
|
🎉 This PR is included in version 6.0.0-next.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |



Fixes #2190
Summary
This PR fixes how the TypeScript generator handles OpenAPI string formats.
Previously, fields with
date-time,date, ortimeformats were treated as plainstring, which resulted in inaccurate generated models.These formats are now correctly mapped to the
Datetype.nextbranch since users of the generator may need to update their types.What changed
TypeScriptConstrainer.tsto checkconstrainedModel.options.formatdate-time,date, andtimeformats toDateapplyNullableto correctly handle optional fieldsReproducing the issue
The issue is reproduced by existing snapshot tests, which fail when these formats are incorrectly generated as
string.After applying this fix, the snapshots were updated and all tests pass.
Testing
date-timefields are output asDateScreenshot